package com.ehotting.edsta.circuitDesign.controller;


import com.ehotting.edsta.circuitDesign.domain.EsSceneParam;
import com.ehotting.edsta.circuitDesign.service.IEsSceneParamService;
import com.ehotting.eaf.core.utils.poi.ExcelUtil;
import com.ehotting.eaf.core.web.controller.BaseController;
import com.ehotting.eaf.core.web.domain.AjaxResult;
import com.ehotting.eaf.core.web.page.TableDataInfo;
import com.ehotting.edsta.common.log.annotation.Log;
import com.ehotting.edsta.common.log.enums.BusinessType;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List;


/**
 * 输入场景参数Controller
 * 
 * @author edsta
 * @date 2023-05-05
 */
@RestController
@RequestMapping("/param")
public class EsSceneParamController extends BaseController
{
    @Autowired
    private IEsSceneParamService esSceneParamService;

    /**
     * 查询输入场景参数列表
     */
//    @PreAuthorize(hasPermi = "edsta:param:list")
    @GetMapping("/list")
    public TableDataInfo list(EsSceneParam esSceneParam)
    {
        startPage();
        List<EsSceneParam> list = esSceneParamService.selectEsSceneParamList(esSceneParam);
        return getDataTable(list);
    }

    /**
     * 查询输入场景参数列表
     */
//    @PreAuthorize(hasPermi = "edsta:param:list")
    @GetMapping("/allList")
    public AjaxResult allList(EsSceneParam esSceneParam)
    {
        List<EsSceneParam> list = esSceneParamService.selectEsSceneParamList(esSceneParam);
        return AjaxResult.success(list);
    }

    /**
     * 导出输入场景参数列表
     */
//    @PreAuthorize(hasPermi = "edsta:param:export")
    @Log(title = "输入场景参数", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, EsSceneParam esSceneParam) throws IOException
    {
        List<EsSceneParam> list = esSceneParamService.selectEsSceneParamList(esSceneParam);
        ExcelUtil<EsSceneParam> util = new ExcelUtil<EsSceneParam>(EsSceneParam.class);
        util.exportExcel(response, list, "输入场景参数数据");
    }

    /**
     * 获取输入场景参数详细信息
     */
//    @PreAuthorize(hasPermi = "edsta:param:query")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(esSceneParamService.selectEsSceneParamById(id));
    }

    /**
     * 新增输入场景参数
     */
//    @PreAuthorize(hasPermi = "edsta:param:add")
    @Log(title = "输入场景参数", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody EsSceneParam esSceneParam)
    {
        return toAjax(esSceneParamService.insertEsSceneParam(esSceneParam));
    }

    /**
     * 修改输入场景参数
     */
//    @PreAuthorize(hasPermi = "edsta:param:edit")
    @Log(title = "输入场景参数", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody EsSceneParam esSceneParam)
    {
        return toAjax(esSceneParamService.updateEsSceneParam(esSceneParam));
    }

    /**
     * 删除输入场景参数
     */
//    @PreAuthorize(hasPermi = "edsta:param:remove")
    @Log(title = "输入场景参数", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(esSceneParamService.deleteEsSceneParamByIds(ids));
    }
}
